let t = require;
let e = module;
let o = e.exports;
o.default = e.exports;

('use strict');
console.log('start');
var _n122,
  i =
    (this && this.__extends) ||
    ((_n122 = function n(t, e) {
      return (_n122 =
        Object.setPrototypeOf ||
        ({
          __proto__: []
        } instanceof Array &&
          function (t, e) {
            t.__proto__ = e;
          }) ||
        function (t, e) {
          for (var o in e) {
            Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
          }
        })(t, e);
    }),
      function (t, e) {
        function o() {
          this.constructor = t;
        }
        _n122(t, e),
          (t.prototype =
            null === e
              ? Object.create(e)
              : ((o.prototype = e.prototype), new o()));
      });
Object.defineProperty(o, '__esModule', {
  value: !0
}),
  (o.MergePanel = void 0);
var r = t('UIComponent'),
  a = t('ComUtils'),
  s = t('SoundMrg'),
  c = t('SoldierItemCfg'),
  l = t('GameSDK'),
  u = t('GeneralTips'),
  h = t('PlayerMrg'),
  p = t('BattleUtils'),
  f = t('CivilizationMrg'),
  d = t('UiEffectCom'),
  g = t('MathUtils'),
  _ = t('MergeMrg'),
  y = t('ConstantCfg'),
  C = t('GridItem'),
  m = t('DragItem'),
  v = t('ResMrg'),
  b = t('BattleMrg'),
  M = t('SoldierItemInfo'),
  I = t('UIMrg'),
  A = t('BuyMoneyPanel'),
  w = t('UmaSdkHelper'),
  P = t('CardGridCom'),
  U = t('WeakGuidePanel'),
  O = t('CardMrg'),
  S = t('SustainMergePanel'),
  T = t('LangCfg'),
  B = (function (t) {
    function e() {
      return (null !== t && t.apply(this, arguments)) || this;
    }
    return (
      i(e, t),
      (e.prototype.onInit = function () {
        (this._counts = []),
          (this._txtSwapCount = a.default.getComponent(
            cc.Label,
            this.view,
            'bottom/buttons/btnSwap/Background/count/txtCount'
          )),
          (this._txtRemoveCount = a.default.getComponent(
            cc.Label,
            this.view,
            'bottom/buttons/btnRemove/Background/count/txtCount'
          )),
          (this._txtMoneyCount = a.default.getComponent(
            cc.Label,
            this.view,
            'bottom/buttons/btnRefresh/Background/count/txtCount'
          )),
          (this._txtMoneyCount.string = y.ConstantCfg.ins
            .getValue(10)
            .toString()),
          (this._txtMoney = a.default.getComponent(
            cc.Label,
            this.view,
            'bottom/items/moneyVal/txtMoney'
          )),
          (this._mask = this.view.getChildByName('mask')),
          (this._startEffect = this.view.getChildByName('startEffect')),
          (this._startAnim = a.default.getComponent(
            sp.Skeleton,
            this._startEffect,
            'StartBattleEffect'
          )),
          this._startAnim.setCompleteListener(
            this.onStartEffectHandler.bind(this)
          ),
          (this._cardGridItems = new P.CardGridCom(
            this.view.getChildByName('card')
          )),
          a.default
            .getNode(this.view, 'bottom/buttons/btnRefresh')
            .on(cc.Node.EventType.TOUCH_END, this.onTouchRefreshHandler, this),
          a.default
            .getNode(this.view, 'bottom/buttons/btnSwap')
            .on(cc.Node.EventType.TOUCH_END, this.onTouchSwapHandler, this),
          a.default
            .getNode(this.view, 'bottom/buttons/btnRemove')
            .on(cc.Node.EventType.TOUCH_END, this.onTouchRemoveHandler, this),
          a.default
            .getNode(this.view, 'bottom/buttons/btnBattle')
            .on(cc.Node.EventType.TOUCH_END, this.onTouchBattleHandler, this),
          (this.canShowWeakGuide = !0),
          this.initItems(),
          this.initEvents();
      }),
      (e.prototype.getMoneyCom = function () {
        return this._txtMoney.node.parent;
      }),
      (e.prototype.getItemCom = function (t) {
        return this._items ? this._items[t] : null;
      }),
      (e.prototype.getGridCom = function (t, e) {
        return this._grids ? this._grids[e][t] : null;
      }),
      (e.prototype.getBattleButton = function () {
        return a.default.getComponent(
          cc.Button,
          this.view,
          'bottom/buttons/btnBattle'
        );
      }),
      (e.prototype.getRefreshButton = function () {
        return a.default.getComponent(
          cc.Button,
          this.view,
          'bottom/buttons/btnRefresh'
        );
      }),
      (e.prototype.getSwapButton = function () {
        return a.default.getComponent(
          cc.Button,
          this.view,
          'bottom/buttons/btnSwap'
        );
      }),
      (e.prototype.getRemoveButton = function () {
        return a.default.getComponent(
          cc.Button,
          this.view,
          'bottom/buttons/btnRemove'
        );
      }),
      (e.prototype.initEvents = function () {
        b.BattleMrg.ins.on(
          b.BattleEvent.MoneyChanged,
          this.onMoneyChangedHandler,
          this
        ),
          b.BattleMrg.ins.on(
            b.BattleEvent.SwapItemChanged,
            this.onSwapItemChangedHandler,
            this
          ),
          b.BattleMrg.ins.on(
            b.BattleEvent.EradicateItemChanged,
            this.onEradicateItemChangedHandler,
            this
          );
      }),
      Object.defineProperty(e.prototype, 'grids', {
        get: function get() {
          return this._grids;
        },
        enumerable: !1,
        configurable: !0
      }),
      (e.prototype.onMoneyChangedHandler = function () {
        var t = a.default.getNode(
          this.view,
          'bottom/buttons/btnRefresh/Background/imgAdVideo'
        );
        b.BattleMrg.ins.money >= y.ConstantCfg.ins.getValue(10)
          ? ((this._txtMoneyCount.node.color = cc.Color.WHITE), (t.active = !1))
          : ((this._txtMoneyCount.node.color = cc.Color.RED), (t.active = !1));
        var e = Math.max(0, b.BattleMrg.ins.money).toString();
        e != this._txtMoney.string &&
          ((this._txtMoney.string = e),
            cc
              .tween(this._txtMoney.node)
              .to(0.1, {
                scale: 1.5
              })
              .to(0.1, {
                scale: 1
              })
              .start());
      }),
      (e.prototype.onSwapItemChangedHandler = function () {
        var t = a.default.getNode(
          this.view,
          'bottom/buttons/btnSwap/Background/imgAdVideo'
        );
        b.BattleMrg.ins.swapItem > 0
          ? ((this._txtSwapCount.string = b.BattleMrg.ins.swapItem.toString()),
            (this._txtSwapCount.node.parent.active = !0),
            (t.active = !1))
          : ((this._txtSwapCount.node.parent.active = !1), (t.active = !0));
      }),
      (e.prototype.onEradicateItemChangedHandler = function () {
        var t = a.default.getNode(
          this.view,
          'bottom/buttons/btnRemove/Background/imgAdVideo'
        );
        b.BattleMrg.ins.eradicateItem > 0
          ? ((this._txtRemoveCount.string =
            b.BattleMrg.ins.eradicateItem.toString()),
            (this._txtRemoveCount.node.parent.active = !0),
            (t.active = !1))
          : ((this._txtRemoveCount.node.parent.active = !1), (t.active = !0));
      }),
      (e.prototype.onShow = function () {
        t.prototype.onShow.call(this),
          (this.view.getChildByName('battleMask').active = !1),
          this.onMoneyChangedHandler(),
          this.onSwapItemChangedHandler(),
          this.onEradicateItemChangedHandler();
      }),
      (e.prototype.onClose = function () {
        if ((t.prototype.onClose.call(this), this._grids)) {
          for (var e = 0; e < this._grids.length; e++) {
            for (var o = this._grids[e], n = 0; n < o.length; n++) {
              o[n].targetOff(this), o[n].clear(), o[n].destroy();
            }
          }
          this._grids = null;
        }
        this._cardGridItems.removeComs();
      }),
      (e.prototype.showBottom = function () {
        var t = this,
          e = this.view.getChildByName('bottom'),
          showorhide = e.getChildByName("showOrHide"),
          o = this.view.getChildByName('grid');
        (e.active = !0), (o.active = !0);
        var n = this.view.getChildByName('battleMask');
        showorhide.active = false;
        cc 
          .tween(n)
          .to(0.2, {
            opacity: 0
          })
          .call(function (t) {
            t.active = !1;
          })
          .start(),
          cc
            .tween(e)
            .to(
              0.5,
              {
                opacity: 255,
                x: 0,
                y: -220
              },
              {
                easing: 'elasticOut'
              }
            )
            .call(function () {
              // 检查是否满足显示引导 2 的条件
              if (h.PlayerMrg.ins.hasGuide(1) || 1 !== t._chapter.id) {
                // 若满足条件，不显示引导 2
              } else {
                // 若不满足条件，显示引导 2
                h.PlayerMrg.ins.showGuide(2);
              }

              // 检查是否满足显示引导 7 的条件
              if (t._chapter.id > y.ConstantCfg.ins.getValue(12) && h.PlayerMrg.ins.hasGuide(7)) {
                // 若满足条件，显示引导 7
                h.PlayerMrg.ins.showGuide(7);
              }
              // 显示 showorhide 节点
              showorhide.active = true;
            })
            .start(),
          this._grids &&
          this._round.round > 1 &&
          this.delayCall(0.5, this.dealWithMoney),
          (this._cardGridItems.view.active = !0),
          cc
            .tween(this._cardGridItems.view)
            .to(0.2, {
              opacity: 0,
              x: 0,
              y: -520
            })
            .call(function (t) {
              t.active = !1;
            })
            .start(),
          s.SoundMrg.playAudio('cutto');
      }),
      (e.prototype.dealWithMoney = function () {
        for (var t, e = 0; e < this._grids.length; e++) {
          for (var o = this._grids[e], n = 0; n < o.length; n++) {
            var i = o[n];
            i.stopBattle(), i.data && i.card && 0 == i.card.type && (t = i);
          }
        }
        t && t.yieldMoney();
      }),
      (e.prototype.hideBottom = function () {
        var t = this.view.getChildByName('bottom');
        let showorhide = t.getChildByName("showOrHide");
        showorhide.active = false;
        cc.tween(t)
          .to(0.2, {
            opacity: 0,
            x: 0,
            y: -520
          })
          .call(function (t) {
            t.active = !1;
          })
          .start();
        var e = this.view.getChildByName('battleMask');
        if (
          ((e.opacity = 0),
            (e.y = 100),
            (e.active = !0),
            cc
              .tween(e)
              .to(0.2, {
                opacity: 255,
                y: 161.5
              })
              .start(),
            this._grids)
        )
          for (var o = 0; o < this._grids.length; o++) {
            for (var n = this._grids[o], i = 0; i < n.length; i++) {
              n[i].startBattle();
            }
          }
        (this._cardGridItems.view.active = !0),
          (this._cardGridItems.view.y = -520),
          cc
            .tween(this._cardGridItems.view)
            .to(
              0.5,
              {
                opacity: 255,
                x: 0,
                y: -220
              },
              {
                easing: 'elasticOut'
              }
            )
            .start(),
          s.SoundMrg.playAudio('cutto');
      }),
      (e.prototype.ready = function (t) {
        (this._round = t),
          (this._refreshs = 0),
          1 == t.round && this.initGrids(),
          (b.BattleMrg.ins.money -= y.ConstantCfg.ins.getValue(10)),
          this.buildItems(),
          this.showBottom();
      }),
      (e.prototype.initItems = function () {
        this._items = [];
        for (var t = 0; t < 3; t++) {
          var e = a.default.getNode(this.view, 'bottom/items/item' + t),
            o = new m.DragItem(e);
          o.on(
            cc.Node.EventType.TOUCH_START,
            this.onTouchItemStartHandler,
            this
          ),
            this._items.push(o);
        }
      }),
      (e.prototype.initGrids = function () {
        var t = this.view.getChildByName('grid'),
          e = t.getChildByName('GridItem'),
          o = this._chapter.grid,
          n = 0.5 * o[0].length * -104 + 52,
          i = 51 * o.length - 51;
        (this._grids = []), (e.active = !1);
        for (var r = 0; r < o.length; r++) {
          var a = o[r];
          this._grids.push([]);
          for (var s = 0; s < a.length; s++) {
            var l = cc.instantiate(e),
              u = new C.GridItem(l, r, s),
              h = c.SoldierItemCfg.ins.getData(this.chapter.grid[r][s]);
            (u.enabled = !1),
              (l.x = n + 104 * s),
              (l.y = i - 102 * r),
              (l.active = !0),
              (u.isNormal = !1),
              (u.moneyCom = this._txtMoney.node),
              h && (u.data = h),
              t.addChild(l),
              this._grids[r].push(u);
          }
        }
        _.MergeMrg.init(this._grids, this.view),
          (this._sustainMerges = 0),
          this.initGridDefItem();
      }),
      (e.prototype.initGridDefItem = function () {
        for (
          var t = p.default.getPresetItems(
            this._round,
            f.CivilizationMrg.ins.data
          ),
          e = 0;
          e < t.length;
          e++
        ) {
          for (; ;) {
            var o = g.default.randomInt(0, this._chapter.size[0] - 1),
              n = g.default.randomInt(0, this._chapter.size[1] - 1);
            if (null == this._grids[n][o].data) {
              this._grids[n][o].data = c.SoldierItemCfg.ins.getData(t[e]);
              break;
            }
          }
        }
        for (n = 0; n < this._grids.length; n++) {
          var i = this._grids[n];
          for (o = 0; o < i.length; o++) {
            i[o].isNormal = !0;
          }
        }
        if (h.PlayerMrg.ins.chapter.id > y.ConstantCfg.ins.getValue(12))
          for (e = 0; e < O.CardMrg.ins.slots.length; e++) {
            var r = O.CardMrg.ins.slots[e];
            if (r.isOpen && r.card)
              for (; ;) {
                (o = g.default.randomInt(0, this._chapter.size[0] - 1)),
                  (n = g.default.randomInt(0, this._chapter.size[1] - 1));
                var a = this._grids[n][o];
                if ((null == a.data || 5 != a.data.type) && null == a.card) {
                  this._grids[n][o].card = r.card;
                  break;
                }
              }
          }
      }),
      Object.defineProperty(e.prototype, 'chapter', {
        get: function get() {
          return this._chapter;
        },
        set: function set(t) {
          this._chapter = t;
        },
        enumerable: !1,
        configurable: !0
      }),
      (e.prototype.onTouchRefreshHandler = function (t) {
        var e = t.currentTarget.getComponent(cc.Button);
        (e && !e.interactable) ||
          (b.BattleMrg.ins.money < y.ConstantCfg.ins.getValue(10)
            ? (I.UIMrg.show(A.BuyMoneyPanel, this.buyItems.bind(this)),
              s.SoundMrg.click())
            : this.buyItems(),
            this.cancelDrag());
      }),
      (e.prototype.buyItems = function () {
        b.BattleMrg.ins.money >= y.ConstantCfg.ins.getValue(10) &&
          ((b.BattleMrg.ins.money -= y.ConstantCfg.ins.getValue(10)),
            this.buildItems());
      }),
      (e.prototype.buildItems = function () {
        var t;
        t =
          h.PlayerMrg.ins.hasGuide(1) &&
            1 == this._round.round &&
            1 == this._chapter.id
            ? [
              new M.SoldierItemInfo(1001),
              new M.SoldierItemInfo(1001),
              new M.SoldierItemInfo(2001)
            ]
            : p.default.genRandSoldierItems(this._round);
        for (var e = 0; e < this._items.length; e++) {
          var o = t[e];
          this._items[e].setData(c.SoldierItemCfg.ins.getData(o.itemId)),
            (this._items[e].enabled = !o.video);
        }
        this._refreshs++, s.SoundMrg.playAudio('reset');
      }),
      (e.prototype.checkDataCount = function () {
        for (var t = 0, e = 0; e < this._grids.length; e++) {
          for (var o = this._grids[e], n = 0; n < o.length; n++) {
            o[n].data && t++;
          }
        }
        return t;
      }),
      (e.prototype.onTouchSwapHandler = function (t) {
        var e = t.currentTarget.getComponent(cc.Button);
        (e && !e.interactable) ||
          (s.SoundMrg.click(),
            this.cancelDrag(),
            b.BattleMrg.ins.swapItem > 0
              ? this.checkDataCount() > 0
                ? ((this._swapItem1 = null),
                  (this._swapItem2 = null),
                  this.setSwapItemState(!0))
                : u.GeneralTips.show(T.LangCfg.ins.getContent(1005))
              : l.default.videoAdBuy(
                4002,
                '交换道具',
                this.videoAdSwapHandler,
                this
              ));
      }),
      (e.prototype.videoAdSwapHandler = function () {
        b.BattleMrg.ins.swapItem++, this.setSwapItemState(!0);
      }),
      (e.prototype.onTouchRemoveHandler = function (t) {
        var e = t.currentTarget.getComponent(cc.Button);
        (e && !e.interactable) ||
          (s.SoundMrg.click(),
            this.cancelDrag(),
            b.BattleMrg.ins.eradicateItem > 0
              ? this.checkDataCount() > 0
                ? this.setRemoveItemState(!0)
                : u.GeneralTips.show(T.LangCfg.ins.getContent(1006))
              : l.default.videoAdBuy(
                4001,
                '铲除道具',
                this.videoAdRemoveHandler,
                this
              ));
      }),
      (e.prototype.videoAdRemoveHandler = function () {
        b.BattleMrg.ins.eradicateItem++, this.setRemoveItemState(!0);
      }),
      (e.prototype.setSwapItemState = function (t) {
        // 遍历网格项
        for (let o = 0; o < this._grids.length; o++) {
          const gridRow = this._grids[o];
          for (let n = 0; n < gridRow.length; n++) {
            const gridItem = gridRow[n];
            if (t) {
              if (gridItem.data && gridItem.data.type <= 3) {
                gridItem.on(cc.Node.EventType.TOUCH_START, this.onTouchItemStartHandler, this);
                gridItem.setSwap(true);
              } else {
                gridItem.setSwap(false);
              }
            } else {
              gridItem.off(cc.Node.EventType.TOUCH_START, this.onTouchItemStartHandler, this);
              gridItem.setSwap(false);
            }
          }
        }

        // 更新交换状态和遮罩层
        this._isSwaping = t;
        this._mask.active = t;

        // 获取描述面板相关组件
        const descPanel = this.view.getChildByName('desc');
        const iconSprite = a.default.getComponent(cc.Sprite, descPanel, 'frame/imgIcon');
        const nameLabel = a.default.getComponent(cc.Label, descPanel, 'frame/txtName');
        const descLabel = a.default.getComponent(cc.Label, descPanel, 'desc/txtDesc');
        const closeButton = descPanel.getChildByName('btnClose');

        // 清空图标精灵帧
        iconSprite.spriteFrame = null;

        if (t) {
          // 设置描述面板内容
          nameLabel.string = T.LangCfg.ins.getContent(201203);
          descLabel.string = T.LangCfg.ins.getContent(201204);
          v.ResMrg.loadSpriteByAtlas(iconSprite, 'Atlas/Battle', '5jiaohuantubiao');
          // 添加关闭按钮触摸结束事件监听器
          closeButton.on(cc.Node.EventType.TOUCH_END, this.onTouchCancelSwapHandler, this);
          descPanel.opacity = 0;
          // 执行淡入动画显示描述面板
          cc.tween(descPanel).to(0.2, { opacity: 255 }).start();
        } else {
          // 移除关闭按钮触摸结束事件监听器
          closeButton.off(cc.Node.EventType.TOUCH_END, this.onTouchCancelSwapHandler, this);
        }

        // 根据 t 的值显示或隐藏描述面板
        descPanel.active = t;
        // 根据 t 的反值显示或隐藏按钮
        this.showOrHideButtons(!t);
        // 根据 t 的反值设置是否可以显示弱引导
        this.canShowWeakGuide = !t;
      }),
      (e.prototype.onTouchCancelSwapHandler = function (t) {
        var e = t.currentTarget.getComponent(cc.Button);
        (e && !e.interactable) || this.setSwapItemState(!1);
      }),
      (e.prototype.itemSwapHandler = function () {
        if (0 == --this._swapCount) {
          var t = this._swapItem1.data;
          (this._swapItem1.data = this._swapItem2.data),
            (this._swapItem2.data = t),
            (this._swapCount = 0),
            (this._sustainMerges = 0),
            this.startMergeToItem(this._swapItem1),
            this.startMergeToItem(this._swapItem2),
            (this._swapItem1 = null),
            (this._swapItem2 = null),
            (this._mask.active = !1);
        }
      }),
      (e.prototype.setRemoveItemState = function (t) {
        for (let gridIndex = 0; gridIndex < this._grids.length; gridIndex++) {
          const grid = this._grids[gridIndex];
          for (let itemIndex = 0; itemIndex < grid.length; itemIndex++) {
            const gridItem = grid[itemIndex];
            if (t) {
              // 开启移除状态，添加触摸结束事件监听器
              gridItem.on(cc.Node.EventType.TOUCH_END, this.onTouchItemRemoveHandler, this);
            } else {
              // 关闭移除状态，移除触摸结束事件监听器
              gridItem.off(cc.Node.EventType.TOUCH_END, this.onTouchItemRemoveHandler, this);
            }
            if (gridItem.data) {
              // 若网格项有数据，设置移除状态
              gridItem.setRemove(t);
            }
          }
        }

        // 根据 t 的值显示或隐藏遮罩层
        this._mask.active = t;

        // 获取描述面板相关组件
        const descPanel = this.view.getChildByName('desc');
        const iconSprite = a.default.getComponent(cc.Sprite, descPanel, 'frame/imgIcon');
        const nameLabel = a.default.getComponent(cc.Label, descPanel, 'frame/txtName');
        const descLabel = a.default.getComponent(cc.Label, descPanel, 'desc/txtDesc');
        const closeButton = descPanel.getChildByName('btnClose');

        // 清空图标精灵帧
        iconSprite.spriteFrame = null;

        if (t) {
          // 开启移除状态，设置描述面板内容
          nameLabel.string = T.LangCfg.ins.getContent(201201);
          descLabel.string = T.LangCfg.ins.getContent(201202);
          v.ResMrg.loadSpriteByAtlas(iconSprite, 'Atlas/Battle', '5chanchutubiao');
          // 为关闭按钮添加触摸结束事件监听器
          closeButton.on(cc.Node.EventType.TOUCH_END, this.onTouchCancelRemoveHandler, this);
          descPanel.opacity = 0;
          // 执行淡入动画显示描述面板
          cc.tween(descPanel)
            .to(0.2, { opacity: 255 })
            .start();
        } else {
          // 关闭移除状态，移除关闭按钮的触摸结束事件监听器
          closeButton.off(cc.Node.EventType.TOUCH_END, this.onTouchCancelRemoveHandler, this);
        }

        // 根据 t 的值显示或隐藏描述面板
        descPanel.active = t;
        // 根据 t 的反值显示或隐藏按钮
        this.showOrHideButtons(!t);
        // 根据 t 的反值设置是否可以显示弱引导
        this.canShowWeakGuide = !t;
      }),
      (e.prototype.onTouchCancelRemoveHandler = function (t) {
        var e = t.currentTarget.getComponent(cc.Button);
        (e && !e.interactable) || this.setRemoveItemState(!1);
      }),
      (e.prototype.onTouchItemRemoveHandler = function (t) {
        null != t.data &&
          (this.setRemoveItemState(!1),
            (t.data = null),
            b.BattleMrg.ins.eradicateItem--,
            d.UiEffectCom.show('EradicateEffect', t.view),
            s.SoundMrg.playAudio('eradicate'));
      }),
      (e.prototype.onTouchBattleHandler = function (t) {
        var e = t.currentTarget.getComponent(cc.Button);
        if (!e || e.interactable) {
          s.SoundMrg.click(), this.cancelDrag(), this.showStartEffect();
          var o = I.UIMrg.getPanel(U.WeakGuidePanel);
          o && o.isShow && I.UIMrg.close(o);
        }
      }),
      (e.prototype.showStartEffect = function () {
        if (this._startAnim) {
          (this._startAnim.node.active = !1),
            (this._startEffect.opacity = 0),
            (this._startEffect.scale = 2),
            (this._startEffect.active = !0);
          var t = this;
          cc.tween(this._startEffect)
            .to(
              0.2,
              {
                scale: 1,
                opacity: 255
              },
              {
                easing: 'quintIn'
              }
            )
            .delay(0.3)
            .call(function () {
              (t._startAnim.node.active = !0),
                t._startAnim.setAnimation(0, 'animation', !1);
            })
            .start();
        }
      }),
      (e.prototype.showOrHideButtons = function (t) {
        var e = a.default.getNode(this.view, 'bottom/buttons');
        e.stopAllActions(),
          t
            ? cc
              .tween(e)
              .to(0.2, {
                y: -191
              })
              .start()
            : cc
              .tween(e)
              .to(0.2, {
                y: -400
              })
              .start();
      }),
      (e.prototype.onStartEffectHandler = function () {
        (this._startEffect.active = !1), this._cardGridItems.removeComs();
        for (var t = 0; t < this._grids.length; t++) {
          for (var e = this._grids[t], o = 0; o < e.length; o++) {
            var n = e[o];
            n.soldier && n.card && this._cardGridItems.addCard(n.card);
          }
        }
        this.hideBottom(), this.emit(b.BattleEvent.StartBattle);
      }),
      (e.prototype.cancelDrag = function () {
        this._curDragItem && (this._curDragItem = null);
      }),
      (e.prototype.onTouchItemStartHandler = function (t, e) {
        if (this._isMerging) return;

        // 设置当前拖动项，清空当前选中项 
        this._curDragItem = t;
        this._curItem = null;

        if (t.enabled) {
          if (!t.isDraging && t.data) {
            const canvas = cc.Canvas.instance.node;
            // 给画布添加触摸事件监听器
            canvas.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchCanvasHandler, this);
            canvas.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCanvasHandler, this);
            canvas.on(cc.Node.EventType.TOUCH_END, this.onTouchCanvasHandler, this);

            // 给物品添加触摸事件监听器
            t.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchItemMoveHandler, this);
            t.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchItemCancelAndEndHandler, this);
            t.on(cc.Node.EventType.TOUCH_END, this.onTouchItemCancelAndEndHandler, this);

            // 开始拖动并更新位置
            t.startDrag();
            t.onDrag(e.touch.getLocation());
          }
          // 播放选择音效
          s.SoundMrg.playAudio('select');
        } else if (t.type === 2) {
          // 给未启用且类型为 2 的物品添加触摸结束事件监听器
          t.on(cc.Node.EventType.TOUCH_END, this.onTouchItemAdVideoHandler, this);
        }
      }),
      (e.prototype.onTouchCanvasHandler = function (t) {
        switch (t.type) {
          case cc.Node.EventType.TOUCH_MOVE:
            this.onTouchItemMoveHandler(this._curDragItem, t);
            break;

          case cc.Node.EventType.TOUCH_CANCEL:
          case cc.Node.EventType.TOUCH_END:
            this.onTouchItemCancelAndEndHandler(this._curDragItem, t);
        }
      }),
      (e.prototype.onTouchItemMoveHandler = function (t, e) {
        var o = this.getOverItem(e.touch.getLocation());
        this._curDragItem.onDrag(e.touch.getLocation()),
          o != this._curItem &&
          (this._curItem && (this._curItem.selected = !1),
            o &&
            (this._isSwaping
              ? (null == o.data || (o.data && o.data.type <= 3)) &&
              (o.selected = !0)
              : null == o.data && (o.selected = !0)),
            (this._curItem = o));
      }),
      (e.prototype.onTouchItemAdVideoHandler = function (t) {
        (this._curDragItem = t),
          t.off(
            cc.Node.EventType.TOUCH_END,
            this.onTouchItemAdVideoHandler,
            this
          ),
          w.default.videoAdBuyItem(),
          l.default.videoAdBuy(
            this._curDragItem.data.id,
            this._curDragItem.data.name,
            this.onItemAdVideoHandler,
            this
          ),
          s.SoundMrg.click();
      }),
      (e.prototype.onItemAdVideoHandler = function () {
        this._curDragItem &&
          ((this._curDragItem.enabled = !0), (this._curDragItem = null));
      }),
      (e.prototype.onTouchItemCancelAndEndHandler = function (t, e) {
        var o = this.getOverItem(e.touch.getLocation());
        this._curDragItem.off(
          cc.Node.EventType.TOUCH_MOVE,
          this.onTouchItemMoveHandler,
          this
        ),
          this._curDragItem.off(
            cc.Node.EventType.TOUCH_CANCEL,
            this.onTouchItemCancelAndEndHandler,
            this
          ),
          this._curDragItem.off(
            cc.Node.EventType.TOUCH_END,
            this.onTouchItemCancelAndEndHandler,
            this
          ),
          cc.Canvas.instance.node.targetOff(this),
          o
            ? this._isSwaping
              ? o != this._curDragItem &&
                (null == o.data || (o.data && o.data.type <= 3))
                ? ((this._swapItem1 = this._curDragItem),
                  (this._swapItem2 = o),
                  (this._swapCount = 2),
                  this._swapItem1.swapToItem(
                    this._swapItem2,
                    this.itemSwapHandler,
                    this
                  ),
                  this._swapItem2.swapToItem(
                    this._swapItem1,
                    this.itemSwapHandler,
                    this
                  ),
                  b.BattleMrg.ins.swapItem--,
                  s.SoundMrg.playAudio('put'),
                  this.setSwapItemState(!1))
                : this._curDragItem.reset()
              : null == o.data
                ? ((o.data = this._curDragItem.data),
                  (this._sustainMerges = 0),
                  this.startMergeToItem(o),
                  this._curDragItem.stopDrag(),
                  (this._curDragItem.data = null),
                  s.SoundMrg.playAudio('put'))
                : this._curDragItem.reset()
            : this._curDragItem.reset(),
          this._curItem &&
          ((this._curItem.selected = !1), (this._curItem = null));
      }),
      (e.prototype.startMergeToItem = function (t) {
        var e = _.MergeMrg.getCanMerge(t);
        if (e) {
          (this._isMerging = !0),
            (this.canShowWeakGuide = !1),
            (e[0].mergeCount = e.length - 1);
          for (var o = 1; o < e.length; o++) {
            e[o].mergeToItem(e[0], this.onMergeToItemHandler, this);
          }
          return !0;
        }
        return !1;
      }),
      (e.prototype.onMergeToItemHandler = function (t) {
        if (0 == --t.mergeCount) {
          var e = c.SoldierItemCfg.ins.getDataByTypeLevel(
            t.data.type,
            t.data.level + 1
          );
          (t.data = e), d.UiEffectCom.show('MergeEffect', t.view);
          var o = this._counts[e.level];
          if (
            (isNaN(o) ? (o = 1) : o++,
              (this._counts[e.level] = o),
              this.startMergeToItem(t) ||
              ((this._isMerging = !1), (this.canShowWeakGuide = !0)),
              this._sustainMerges++,
              this._sustainMerges > 1)
          ) {
            var n = {
              count: this._sustainMerges,
              grid: t
            };
            I.UIMrg.show(S.SustainMergePanel, n);
          }
          s.SoundMrg.playAudio('merge');
        }
      }),
      (e.prototype.getOverItem = function (t) {
        for (var e, o = 0; o < this._grids.length; o++) {
          e = this._grids[o];
          for (var n = 0; n < e.length; n++) {
            var i = e[n];
            if (i.check(t)) return i;
          }
        }
        return null;
      }),
      e
    );
  })(r.UIComponent);
(o.MergePanel = B), console.log('end');
module.exports = e.exports;
